<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%--
  Created by IntelliJ IDEA.
  User: ghp
  Date: 2022/10/4
  Time: 11:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>c_foreach1</title>
</head>
<body>
<%--遍历String数组--%>
<%
    String[] fruits = {"apple","orange","grape","banana"};
    pageContext.setAttribute("fruits",fruits);
%>
fruits数组中的元素有:<br/>
<c:forEach var="fruit" items="${fruits}">
    ${fruit}<br/>
</c:forEach>
<%--遍历Map集合--%>
<%
    /*JDK明明是1.8但是还是报版本过低*/
    Map<String,String> maps = new HashMap<String,String>();
    maps.put("张三","123");
    maps.put("李四","456");
    maps.put("王五","789");
    pageContext.setAttribute("maps",maps);
%>
map集合中的元素有:<br/>
<c:forEach var="map" items="${maps}">
    ${map.key}=${map.value}<br/>
</c:forEach>
</body>
</html>
